<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no"/>

	
<title>悦章科技机构平台</title>	
<script src="/Public/static/jquery-2.0.3.min.js"></script>
<script src="/Public/static/layer/layer.js"></script>
<script src="/Public/static/jPages.js"></script>
<!--内容样式-->
<link rel="stylesheet" href="__PUBLIC__/Home/css/style.css" />
<link rel="stylesheet" href="__PUBLIC__/Home/css/page.css" />
<style>
    .holder a{border:1px solid #e1e1e1;color:#909090;cursor:pointer;}
    .jp-current{padding:6px 6px;border:1px solid #e1e1e1;background:#f55555;cursor:pointer;}
    .holder .jp-current{color:#fff;cursor:pointer;}
    .page{margin: 0 0 0 0}
</style>
</head>

<body>

	
	<div class="main">
	
	
		<include file="menu" />
		
		
		
		<!--  右侧内容  -->
		<div class="content">
			
			
			<div class= "ct-title">
				<div class="ctt-bt">点播课管理</div>
				<div class="ctt-r">
					<form class="cttr-bd" action="" method="POST">
						<input type="text" placeholder="请输入课程名称" name="name" class="cttrb-wb" value="{$msg.name}">
						<select class="cttrb-xl" name="two_type_id">
							<option value="">选择课程类型</option>
							<volist name="t_list" id="item">
								<option value="{$item['id']}" <if condition="$msg.two_type_id eq $item['id']">selected</if>>{$item['name']}</option>
							</volist>
						</select>
						<select class="cttrb-xl" name="is_upper">
							<option value=""  <if condition="$msg.is_upper eq '11'">selected</if>>状态</option>
							<option value="1" <if condition="$msg.is_upper eq 1">selected</if>>上架</option>
							<option value="0" <if condition="$msg.is_upper eq 0">selected</if>>下架</option>
						</select>
						<select class="cttrb-xl" name="is_recommend">
							<option value="">是否推荐</option>
							<option value="2" <if condition="$msg.is_recommend eq 2">selected</if>>已推荐</option>
							<option value="1" <if condition="$msg.is_recommend eq 1">selected</if>>未推荐</option>
						</select>
						<button class="cttrb-cx" type="submit">查询</button>
						<!-- <div class="cttrb-fp" onClick="document.getElementById('tck-xksm').style.display='block'">选课售卖</div> -->
						<div class="cttrb-fp" onclick="showCourse()">选课售卖</div>
						<div class="cttrb-xz" onClick="document.getElementById('tck-sqzy').style.display='block'">申请自营</div>
						<div class="divclear"></div>
					</form>
					<div class="divclear"></div>
				</div>
				<div class="divclear"></div>
			</div>
			
			<div class="ct-table">
				<table width="100%" border="0">
					<tbody>
						<tr>
							<th scope="col" width="26%" style="border-top-left-radius: 10px;">课程名称</th>
							<th scope="col" width="7%">课程类型</th>
							<th scope="col" width="5%">集数</th>
							<th scope="col" width="5%">单价</th>
							<!-- <th scope="col" width="9%">本次过期日期</th> -->
							<th scope="col" width="9%">累计购买数量</th>
							<th scope="col" width="9%">是否关联书籍</th>
							<th scope="col" width="7%">是否推荐</th>
							<th scope="col" width="5%">状态</th>
							<th scope="col" width="18%" style="border-top-right-radius: 10px;">操作</th>
						</tr>
						<volist name="_list" id="item">
							<tr>
							  <td>
								<div class="ctt-img ctt-img2">
									<img src="{$item.img}" />  
								</div>
								<div class="ctt-kcm">{$item['name']}</div>
								<div class="divclear"></div>
							  </td>
							  <td>{$item['type_name']}</td>
							  <td>{$item['count']}</td>
							  <td>￥{$item['price']}</td>
							  <!-- <td></td> -->
							  <td>{$item['count_number']}人</td>
							  <td>{$item['is_book']}</td>
							  <td>{$item['recommend']}</td>
							  <td>{$item['upper']}</td>
							  <td><if condition="$item['is_upper'] eq 1"><a href="{:U('Operate/loadingAndUnloadingVideoCourse',array('id'=>$item['id'],'is_upper'=>0))}">下架</a><else/><a href="{:U('Operate/loadingAndUnloadingVideoCourse',array('id'=>$item['id'],'is_upper'=>1))}">上架</a></if><a href="{:U('Operate/video_detail',array('id'=>$item['id']))}">详情</a><if condition="$item['is_recommend'] eq 1"><a href="{:U('Operate/recommend',array('id'=>$item['id'],'is_recommend'=>2))}">推荐</a><else/><a href="{:U('Operate/recommend',array('id'=>$item['id'],'is_recommend'=>1))}">取消推荐</a></if><a onClick="document.getElementById('tck-xgjg').style.display='block'" data-z="{$item['id']}" id="zz">修改</a><a href="{:U('Operate/delVideoCourse',array('id'=>$item['id']))}">删除</a></td>
							</tr>
						</volist>
					</tbody>
				</table>
			</div>
			
<!-- 			<div class="ct-btn">
				<div class="ctb-an"><</div>
				<div class="ctb-an ctb-an-on">1</div>
				<div class="ctb-an">2</div>
				<div class="ctb-an">3</div>
				<div class="ctb-an">></div>
				<div class="divclear"></div>
			</div> -->
			<input type="hidden" name="id">
			<div class="page">
	            {$_page}
	        </div>
			
			
		</div>
		
		
		
	</div>
		
		
		
		
		
		
	<!--申请自营 弹出框-->
	<div class="tck-demo" id="tck-sqzy">
		
		<div class="tk-box" style="width: 400px;height: 350px;">
			<div class="tkb-title">
				<div class="tkbt-bt">申请自营</div>
				<div class="tkbt-close" onClick="document.getElementById('tck-sqzy').style.display='none'">
					<img src="__PUBLIC__/Home/images/icon_delete.png" />
				</div>
				<div class="divclear"></div>
			</div>
			<div class="tkb-sqzy">
				<h3>培训机构拥有自营课程时，可发起申请</h3>
				<p>申请须知：培训机构拥有自营课程时，可发起申请,培训机构拥有自营课程时，可发起申请</p>
			</div>
			<div class="tkb-qr">提交申请</div>
		</div>
		
	</div>	
		
		
		
		
		
	<!--修改价格 弹出框-->
	<div class="tck-demo" id="tck-xgjg">
		
		<div class="tk-box" style="width: 400px;height: 350px;">
			<div class="tkb-title">
				<div class="tkbt-bt">过期日期</div>
				<div class="tkbt-close" onClick="document.getElementById('tck-xgjg').style.display='none'">
					<img src="__PUBLIC__/Home/images/icon_delete.png" />
				</div>
				<div class="divclear"></div>
			</div>
			<div class="tkb-zdfp">
<!-- 				<div class="tkbz-bt">单价：</div>
				<div class="tkbz-box">
					<input type="text" placeholder="请输入新的单价" class="tkbzb-l" name="new_price">
					<div class="tkbzb-r">元</div>
					<div class="divclear"></div>
				</div> -->
				<div class="tkbz-bt">过期日期：</div>
				<div class="tkbz-box">
					<input type="text" class="tkbzb-l" style="width: 100%;" name="gq" placeholder="0代表永远有效">
					<div class="divclear"></div>
				</div>
			</div>
			<div class="tkb-qr xg">确定</div>
		</div>
		
	</div>		
		
		
		
		
	<!-- 选课售卖 弹出框-->
	<div class="tck-demo" id="tck-xksm">
		
		<div class="tk-box">
			<div class="tkb-title">
				<div class="tkbt-bt">选课售卖</div>
				<div class="tkbt-close" onClick="document.getElementById('tck-xksm').style.display='none'">
					<img src="__PUBLIC__/Home/images/icon_delete.png" />
				</div>
				<div class="divclear"></div>
			</div>
			<div class="tkb-fpxs">
				<form class="tkbf-top">
					<select class="tkbft-xl yi" name="one_type_id" onchange="dem()">
						<option>一级类别</option>
						<volist name="type_list" id="item">
							<option value="{$item['id']}">{$item['name']}</option>
						</volist>
					</select>
					<select class="tkbft-xl er">
						<option>二级类别</option>
					</select>
					<input type="text" class="tkbft-wb2" placeholder="输入课程名称搜索" style="width:404px;">
					<div class="tkbft-ss" id="sub">搜索</div>
					<div class="divclear"></div>
				</form>
			</div>
			<table width="100%" border="0" class="tkb-table">
				<tbody>
					<tr>
						<th scope="col" width="40%" style="background: #fff;">课程</th>
						<th scope="col" width="14%" style="background: #fff;">一级分类</th>
						<th scope="col" width="14%" style="background: #fff;">二级分类</th>
						<th scope="col" width="10%" style="background: #fff;">官方售价</th>
						<th scope="col" width="10%" style="background: #fff;">集数</th>
						<th scope="col" width="12%" style="background: #fff;">操作</th>
					</tr>
					<tbody class="course"  id="itemContainer">
						<volist name="platform_list" id="item">
							<tr>
							  <td>
								<div class="tkbt-img">
									<img src="{$item['img']}" />  
								</div>
								<div class="tkbt-wz">{$item['name']}</div>
								<div class="divclear"></div>
							  </td>
							  <td>{$item['one_type_name']}</td>
							  <td>{$item['two_type_name']}</td>
							  <td>￥{$item['price']}</td>
							  <td>{$item['count']}</td>
							  <td><a href="{:U('Operate/pre_sale',array('id'=>$item['id']))}">加入预售</a></td>
							</tr>
						</volist>
					</tbody>
				</tbody>
			</table>
			<div class="tkb-btn" style="width: auto;padding: 0;float: left;margin: 20px 0 0 20px;">
	            <div class="page">
	                <div class="holder" style="font-size:12px;"></div>
	            </div>
	        </div>
		</div>
		
	</div>	
		
		
	
	
	
</body>
</html>
<script type="text/javascript">
	function dem(){
		var pid=$('.yi option:selected').val();
		$.ajax({
            url:"{:U('Operate/getChildType')}",
            data:{pid:pid},
            dataType:'json',
            type:'post',
            success:function(data){
                var hh='';
                $.each(data.data,function(k,v){
                 hh +='<option value='+v.id+'>'+v.name+'</option>';
                });
            	$('.er').html(hh);
            }
        })
	}
	    //点击搜索的时候
    $("#sub").click(function(){
    	// alert(432);return false;
    	var type_id=$('.er option:selected').val();
    	if(type_id ==''){
    		alert('请选择二级分类');return false;
    	}
    	var name=$("input[name='name']").val();
    	var type=3;//后台判断加入过预售这里进来的
    	$.ajax({
            url:"{:U('Operate/getCourse')}",
            data:{type_id:type_id,name:name,type:type},
            dataType:'json',
            type:'post',
            success:function(data){
            	// console.log(data.data);return false;
            	var hh='';
                $.each(data.data,function(k,v){
					hh+='<tr>';
					hh+='<td>';
					hh+='<div class="tkbt-img">';
					hh+='<img src="'+v.img+'" />';  
					hh+='</div>';
					hh+='<div class="tkbt-wz">'+v.name+'</div>';
					hh+='<div class="divclear"></div>';
					hh+='</td>';
					hh+='<td>'+v.one_type_name+'</td>';
					hh+='<td>'+v.two_type_name+'</td>';
					hh+='<td>￥'+v.price+'</td>';
					hh+='<td>'+v.count+'</td>';
					hh+='<td><a href="<?php echo "http://" . $_SERVER['HTTP_HOST']?>/index.php?s=/Home/Operate/pre_sale/id/'+v.id+'">加入预售</a></td>';
					hh+='</tr>';
                });
            	$('.course').html(hh);
            	$("div.holder").jPages({
                    containerID : "itemContainer",
                    perPage: 3
                });
            }
        })
    })

    $('body').on('click','#zz', function(){
    	var z=$(this).data('z');
    	$("input[name='id']").val(z);
    })
    $('body').on('click','.xg', function(){
    	// var new_price=$("input[name='new_price']").val();
    	var gq=$("input[name='gq']").val();
    	var id=$("input[name='id']").val();
    	$.ajax({
            url:"{:U('Operate/overdue')}",
            data:{id:id,buy_expire_day:gq},
            dataType:'json',
            type:'post',
            success:function(data){
            if(data.result == 1){
            　　alert('修改成功');
    			var url = "{:U('Operate/videoCourse')}";
                location.href=url;

　　　　　　　}else{
				alert('修改失败');
				var url = "{:U('Operate/videoCourse')}";
	            location.href=url;

			}
            }
        })
    })
    //显示课程弹出框
    function showCourse()
    {
        $("#tck-xksm").show();
        $("div.holder").jPages({
            containerID : "itemContainer",
            perPage: 3
        });
    }
</script>